package com.ttt.controller;

/*
总览信息获取林果基本信息
 */

import com.fasterxml.jackson.core.JsonProcessingException;
import com.ttt.servicer.impl.OverviewDataImpl;
import com.ttt.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("overview")
@CrossOrigin
public class OverviewInformController {

    @Autowired
    private OverviewDataImpl overviewDataImpl;


    //获取林果基本信息
    @PostMapping("/overData")
    public Result findData() throws JsonProcessingException {
        System.out.println("进入成功");
        //调用service层代码
        Result result = overviewDataImpl.findAllData();
        return result;
    }

    //获取健康等级分布数据
    @PostMapping("/healthRating")
    public Result healthRating() throws JsonProcessingException {
        //调用service
        Result result = overviewDataImpl.findHealth();
        return result;
    }

    //获取总产量
    @PostMapping("/allYield")
    public Result allYield() throws JsonProcessingException {

        Result result = overviewDataImpl.findAllYield();
        return result;
    }


    @PostMapping("/avgHealth")
    //获取平均健康指数
    public Result avgHealth() throws JsonProcessingException {

        //调用service的方法
        Result result = overviewDataImpl.findAvgHealth();

        return result;
    }

    //获取各个林果的，类型和数量

    @PostMapping("/getType")
    public Result getType() throws JsonProcessingException {
        //调用service的代码

        Result result = overviewDataImpl.findType();

        return result;
    }

    //获取病害数
    @PostMapping("/getDisease")
    public Result getDisease() throws JsonProcessingException {
        //调用service接口
        Result result = overviewDataImpl.findDisease();
        return result;
    }



    @PostMapping("/getDiseaseCount")
    //获取各个受灾信息-->灾害报警信息那个时间检测预警的次数
    public Result getDiseaseCount() throws JsonProcessingException {
        //调用service方法
        Result result = overviewDataImpl.findDiseaseCount();

        return result;
    }


    //获取各个各个受灾类型及其次数

    @PostMapping("/getDiseaseTypeCount")
    public Result getDiseaseTypeCount() throws JsonProcessingException {

        //调用service
        Result result = overviewDataImpl.findDiseaseTypeCount();
        return result;
    }


    @PostMapping("/getPositionInfo")
    //获取获取各个检测地点信息（林果名称和地址以及最近检查时间）
    public Result getPositionInfo() throws JsonProcessingException {

        //调用service层方法
        Result result = overviewDataImpl.findPositionInfo();

        return result;
    }


    //获取各个林果地的产量

    @PostMapping("/getYield")
    public Result getYield() throws JsonProcessingException {
        //调用service的方法
        Result result = overviewDataImpl.findYield();
        return result;
    }


    //获取检测点位信息
    @PostMapping("/getEquipmentInfo")
    public Result getEquipmentInfo() throws JsonProcessingException {

        //调用service的信息
        Result result = overviewDataImpl.findEquipmentInfo();

        return result;
    }



    //获取田间管理数据
    @PostMapping("/getFieldManagerInfo")
    public Result getFieldManagerInfo() throws JsonProcessingException {

        Result result = overviewDataImpl.findFieldManagerInfo();

        return result;
    }





}
